//
//  AfterSaleServiceTableViewCell.swift
//  OnceNectar
//
//  Created by apple on 2018/3/6.
//  Copyright © 2018年 com.inwhoop. All rights reserved.
//

import UIKit

protocol AfterSaleServiceTableViewCellDelegate:NSObjectProtocol {
    func req(cell:AfterSaleServiceTableViewCell)
}

class AfterSaleServiceTableViewCell: UITableViewCell {
    @IBOutlet var goodsImg: UIImageView!
    @IBOutlet var name: UILabel!
    @IBOutlet var price: UILabel!
    @IBOutlet var spec: UILabel!
    @IBOutlet weak var reqBtn: UIButton!
    weak var delegate: AfterSaleServiceTableViewCellDelegate?
    var model:purcharseModel?
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        
        reqBtn.layer.cornerRadius = reqBtn.mj_h / 2
        reqBtn.layer.masksToBounds = true
    }
    
    func setData(model:purcharseModel) {
        self.model = model
        goodsImg.sd_setImage(with: appendUrl(suffix: model.imageUrl!), completed: nil)
        name.text = model.goodsName
        price.text = "¥" + model.price!
        spec.text = model.specAndCol
        if self.model?.type == "2" {
            reqBtn.isEnabled = false
        }else {
            reqBtn.isEnabled = true
        }
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

    }
    
    @IBAction func reqClick(_ sender: Any) {
        self.delegate?.req(cell: self)
    }
}
